package lab03.test04;

import java.io.*;

/**
 * Created by mac on 2017/12/30.
 */
public class Test {

    public static void main(String[] args) {

        //首先在D盘下创建文件夹source和target
        String source = "D:\\source\\high.mp3";
        String target = "D:\\target\\";
        BufferedWriter writer = null;
        BufferedReader reader = null;
        try {

            //source文件夹中存放“High.mp3”，
            // 使用字节输入流读入文件，使用字节输出流写入文件夹target下
            reader = new BufferedReader(new FileReader(source));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            File file = new File(target);
            if (!file.exists()) file.mkdir();
            try {
                writer = new BufferedWriter(new FileWriter("D:\\target\\high.mp3"));
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                writer.write(reader.read());
            } catch (IOException e) {
                e.printStackTrace();

            }
            for (File f : file.listFiles()) {
                if (f.isFile()) {
                    System.out.println("文件：" + f.getName());
                }
            }
        }finally {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }


}
